package com.hx.staticState.demo1;

import java.util.Date;

/**
 * @Author： Huathy
 * @ClassPath： com.hx.staticState.demo1.Video
 * @Date： 2021-02-01 09:23
 * @Description：
 */

/**
 * 实现克隆的步骤：
 * 1. 实现一个接口：Cloneable
 * 2. 重写一个方法：clone()
 * 深拷贝的方式
 */
public class Video2 implements Cloneable {
    private String name;
    private Date createTime;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Object obj = super.clone();
        Video2 v = (Video2) obj;
        /**
         * 深拷贝
         * 拷贝时，将改对象的属性也进行一个拷贝
         */
        v.createTime = (Date) this.createTime.clone();
        return obj;
    }

    public Video2() {
    }

    public Video2(String name, Date createTime) {
        this.name = name;
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "Video{" +
                "name='" + name + '\'' +
                ", createTime=" + createTime +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
